package me.zhengjie.dto.sqlServer;

import com.fasterxml.jackson.annotation.JsonFormat;
import lombok.Data;
import cn.hutool.core.bean.BeanUtil;
import io.swagger.annotations.ApiModelProperty;
import cn.hutool.core.bean.copier.CopyOptions;
import javax.persistence.*;
import javax.validation.constraints.NotBlank;
import javax.validation.constraints.NotNull;
import java.sql.Timestamp;
import java.io.Serializable;
import java.time.LocalDateTime;

@Entity
@Data
@Table(name="task_result")
public class TaskResult implements Serializable{

    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    @Column(name = "`id`")
    @ApiModelProperty(value = "id")
    private Integer id;

    @Column(name = "`wms_task_id`")
    @NotNull
    @ApiModelProperty(value = "任务id")
    private String wmsTaskId;

    @Column(name = "`wcs_task_type`")
    @NotNull
    @ApiModelProperty(value = "任务类型")
    private Integer wcsTaskType;

    @Column(name = "`lpn_code`")
    @ApiModelProperty(value = "容器编码")
    @NotBlank
    private String lpnCode;

    @Column(name = "`from_location`")
    @ApiModelProperty(value = "实际取货地址")
    private String fromLocation;

    @Column(name = "`to_location`")
    @ApiModelProperty(value = "实际送货地址")
    private String toLocation;

    @Column(name = "`created`")
    @ApiModelProperty(value = "实际完成时间")
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss",timezone = "GMT+8")
    private LocalDateTime created;

    @Column(name = "`status`")
    @ApiModelProperty(value = "任务状态")
    private Integer status;

    @Column(name = "`issue_code`")
    @ApiModelProperty(value = "错误代码")
    private Integer issueCode;

    @Column(name = "`message`")
    @ApiModelProperty(value = "异常原因")
    private String message;

    @Column(name = "`last_updated`")
    @ApiModelProperty(value = "最后更新时间")
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss",timezone = "GMT+8")
    private LocalDateTime lastUpdated;

    public void copy(TaskResult source){
        BeanUtil.copyProperties(source,this, CopyOptions.create().setIgnoreNullValue(true));
    }
}
